package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sl.domain.SlMonthWs;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlMonthOfc;
import com.ruoyi.sl.service.ISlMonthOfcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政固定工资Controller
 * 
 * @author admin
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/sl/monthofc")
public class SlMonthOfcController extends BaseController
{
    @Autowired
    private ISlMonthOfcService slMonthOfcService;

    /**
     * 查询行政固定工资列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlMonthOfc slMonthOfc)
    {
        startPage();
        List<SlMonthOfc> list = slMonthOfcService.selectSlMonthOfcList(slMonthOfc);
        return getDataTable(list);
    }

    /**
     * 条件查询车间工资列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:list')")
    @GetMapping("/rangelist")
    public TableDataInfo rangelist(SlMonthOfc slMonthOfc)
    {
        startPage();
        List<SlMonthOfc> list = slMonthOfcService.selectSlMonthOfcListByRange(slMonthOfc);
        return getDataTable(list);
    }


    /**
     * 导出行政固定工资列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:export')")
    @Log(title = "行政固定工资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlMonthOfc slMonthOfc)
    {
        List<SlMonthOfc> list = slMonthOfcService.selectSlMonthOfcList(slMonthOfc);
        ExcelUtil<SlMonthOfc> util = new ExcelUtil<SlMonthOfc>(SlMonthOfc.class);
        util.exportExcel(response, list, "行政固定工资数据");
    }

    /**
     * 获取行政固定工资详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:query')")
    @GetMapping(value = "/{ofcmpayId}")
    public AjaxResult getInfo(@PathVariable("ofcmpayId") Long ofcmpayId)
    {
        return success(slMonthOfcService.selectSlMonthOfcByOfcmpayId(ofcmpayId));
    }

    /**
     * 新增行政固定工资
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:add')")
    @Log(title = "行政固定工资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlMonthOfc slMonthOfc)
    {
        return toAjax(slMonthOfcService.insertSlMonthOfc(slMonthOfc));
    }

    /**
     * 修改行政固定工资
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:edit')")
    @Log(title = "行政固定工资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlMonthOfc slMonthOfc)
    {
        return toAjax(slMonthOfcService.updateSlMonthOfc(slMonthOfc));
    }

    /**
     * 删除行政固定工资
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:remove')")
    @Log(title = "行政固定工资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ofcmpayIds}")
    public AjaxResult remove(@PathVariable Long[] ofcmpayIds)
    {
        return toAjax(slMonthOfcService.deleteSlMonthOfcByOfcmpayIds(ofcmpayIds));
    }
}
